require 'rubygems'
require 'hpricot'
require "open-uri"

namespace :weather_com_cn do  
  desc "tool_weather_forecast"
  
  task :alert => :environment do 
    Info.capture_weather_alerts!
  end
  
  task :remove_alerts_2_days_ago => :environment do     
    Info.delete_all ['info_type_id = ? and created_at <= ?', InfoType.find_by_code('weather_alert').id, 2.days.ago]
  end
  
  task :capture_cities => :environment do
    doc = Hpricot(open('http://www.weather.com.cn/static/html/weather_list.shtml'))
    doc.search('div.tmapin_citylist').each do |province|
      puts "## #{province.at('p').inner_html}"
      province.search('ul li a').each do |city|
        puts "puts '#{city.innerHTML}--#{city.attributes['href']}' if City.find_by_weather_com_cn_code_and_name('#{city.attributes['href']}',' #{city.innerHTML}').nil?"
      end
    end
  end
  
  task :capture_areas => :environment do
    City.all.each do |city|
      doc = Hpricot(open("http://www.weather.com.cn/weather/#{city.weather_com_cn_code}.shtml"))
      puts "# #{city.name}- http://www.weather.com.cn/weather/#{city.weather_com_cn_code}.shtml"
      doc.search('div.topSj div.mainNav div.navbox span a').each do |area_link|
        puts "Area.create!( :province_id => City.find_by_name('#{city.name}').province_id, :city_id => City.find_by_name('#{city.name}').id, :weather_com_cn_code => '#{area_link.attributes['href']}', :name => '#{area_link.inner_html}') " if not area_link.inner_html =~ /气象局/
      end
    end
  end
  
  task :capture => :environment do
    Area.capture_weather_infos
  end
  
  task :send_emails => :environment do
    UserToolSetting::WeatherForecast.send_emails
  end
  
  task :send_sms => :environment do
    UserToolSetting::WeatherForecast.send_sms(2)
  end
  
  task :test_cities => :environment do 
    ## 直辖市
    puts '北京--101010100 is not exists' if City.find_by_weather_com_cn_code_and_name('101010100','北京').nil?
    puts '重庆--101040100 is not exists' if City.find_by_weather_com_cn_code_and_name('101040100','重庆').nil?
    puts '上海--101020100 is not exists' if City.find_by_weather_com_cn_code_and_name('101020100','上海').nil?
    puts '天津--101030100 is not exists' if City.find_by_weather_com_cn_code_and_name('101030100','天津').nil?
    ## 特区
    puts '澳门--101330101 is not exists' if City.find_by_weather_com_cn_code_and_name('101330101','澳门').nil?
    puts '香港--101320101 is not exists' if City.find_by_weather_com_cn_code_and_name('101320101','香港').nil?
    ## 安徽
    puts '合肥--101220101 is not exists' if City.find_by_weather_com_cn_code_and_name('101220101','合肥').nil?
    puts '蚌埠--101220201 is not exists' if City.find_by_weather_com_cn_code_and_name('101220201','蚌埠').nil?
    puts '芜湖--101220301 is not exists' if City.find_by_weather_com_cn_code_and_name('101220301','芜湖').nil?
    puts '淮南--101220401 is not exists' if City.find_by_weather_com_cn_code_and_name('101220401','淮南').nil?
    puts '马鞍山--101220501 is not exists' if City.find_by_weather_com_cn_code_and_name('101220501','马鞍山').nil?
    puts '安庆--101220601 is not exists' if City.find_by_weather_com_cn_code_and_name('101220601','安庆').nil?
    puts '宿州--101220701 is not exists' if City.find_by_weather_com_cn_code_and_name('101220701','宿州').nil?
    puts '阜阳--101220801 is not exists' if City.find_by_weather_com_cn_code_and_name('101220801','阜阳').nil?
    puts '亳州--101220901 is not exists' if City.find_by_weather_com_cn_code_and_name('101220901','亳州').nil?
    puts '黄山--101221001 is not exists' if City.find_by_weather_com_cn_code_and_name('101221001','黄山').nil?
    puts '滁州--101221101 is not exists' if City.find_by_weather_com_cn_code_and_name('101221101','滁州').nil?
    puts '淮北--101221201 is not exists' if City.find_by_weather_com_cn_code_and_name('101221201','淮北').nil?
    puts '铜陵--101221301 is not exists' if City.find_by_weather_com_cn_code_and_name('101221301','铜陵').nil?
    puts '宣城--101221401 is not exists' if City.find_by_weather_com_cn_code_and_name('101221401','宣城').nil?
    puts '六安--101221501 is not exists' if City.find_by_weather_com_cn_code_and_name('101221501','六安').nil?
    puts '巢湖--101221601 is not exists' if City.find_by_weather_com_cn_code_and_name('101221601','巢湖').nil?
    puts '池州--101221701 is not exists' if City.find_by_weather_com_cn_code_and_name('101221701','池州').nil?
    ## 福建
    puts '福州--101230101 is not exists' if City.find_by_weather_com_cn_code_and_name('101230101','福州').nil?
    puts '厦门--101230201 is not exists' if City.find_by_weather_com_cn_code_and_name('101230201','厦门').nil?
    puts '宁德--101230301 is not exists' if City.find_by_weather_com_cn_code_and_name('101230301','宁德').nil?
    puts '莆田--101230401 is not exists' if City.find_by_weather_com_cn_code_and_name('101230401','莆田').nil?
    puts '泉州--101230501 is not exists' if City.find_by_weather_com_cn_code_and_name('101230501','泉州').nil?
    puts '漳州--101230601 is not exists' if City.find_by_weather_com_cn_code_and_name('101230601','漳州').nil?
    puts '龙岩--101230701 is not exists' if City.find_by_weather_com_cn_code_and_name('101230701','龙岩').nil?
    puts '三明--101230801 is not exists' if City.find_by_weather_com_cn_code_and_name('101230801','三明').nil?
    puts '南平--101230901 is not exists' if City.find_by_weather_com_cn_code_and_name('101230901','南平').nil?
    ## 甘肃
    puts '兰州--101160101 is not exists' if City.find_by_weather_com_cn_code_and_name('101160101','兰州').nil?
    puts '定西--101160201 is not exists' if City.find_by_weather_com_cn_code_and_name('101160201','定西').nil?
    puts '平凉--101160301 is not exists' if City.find_by_weather_com_cn_code_and_name('101160301','平凉').nil?
    puts '庆阳--101160401 is not exists' if City.find_by_weather_com_cn_code_and_name('101160401','庆阳').nil?
    puts '武威--101160501 is not exists' if City.find_by_weather_com_cn_code_and_name('101160501','武威').nil?
    puts '金昌--101160601 is not exists' if City.find_by_weather_com_cn_code_and_name('101160601','金昌').nil?
    puts '张掖--101160701 is not exists' if City.find_by_weather_com_cn_code_and_name('101160701','张掖').nil?
    puts '酒泉--101160801 is not exists' if City.find_by_weather_com_cn_code_and_name('101160801','酒泉').nil?
    puts '天水--101160901 is not exists' if City.find_by_weather_com_cn_code_and_name('101160901','天水').nil?
    puts '武都--101161001 is not exists' if City.find_by_weather_com_cn_code_and_name('101161001','武都').nil?
    puts '临夏--101161101 is not exists' if City.find_by_weather_com_cn_code_and_name('101161101','临夏').nil?
    puts '合作--101161201 is not exists' if City.find_by_weather_com_cn_code_and_name('101161201','合作').nil?
    puts '白银--101161301 is not exists' if City.find_by_weather_com_cn_code_and_name('101161301','白银').nil?
    ## 广东
    puts '广州--101280101 is not exists' if City.find_by_weather_com_cn_code_and_name('101280101','广州').nil?
    puts '韶关--101280201 is not exists' if City.find_by_weather_com_cn_code_and_name('101280201','韶关').nil?
    puts '惠州--101280301 is not exists' if City.find_by_weather_com_cn_code_and_name('101280301','惠州').nil?
    puts '梅州--101280401 is not exists' if City.find_by_weather_com_cn_code_and_name('101280401','梅州').nil?
    puts '汕头--101280501 is not exists' if City.find_by_weather_com_cn_code_and_name('101280501','汕头').nil?
    puts '深圳--101280601 is not exists' if City.find_by_weather_com_cn_code_and_name('101280601','深圳').nil?
    puts '珠海--101280701 is not exists' if City.find_by_weather_com_cn_code_and_name('101280701','珠海').nil?
    puts '佛山--101280800 is not exists' if City.find_by_weather_com_cn_code_and_name('101280800','佛山').nil?
    puts '肇庆--101280901 is not exists' if City.find_by_weather_com_cn_code_and_name('101280901','肇庆').nil?
    puts '湛江--101281001 is not exists' if City.find_by_weather_com_cn_code_and_name('101281001','湛江').nil?
    puts '江门--101281101 is not exists' if City.find_by_weather_com_cn_code_and_name('101281101','江门').nil?
    puts '河源--101281201 is not exists' if City.find_by_weather_com_cn_code_and_name('101281201','河源').nil?
    puts '清远--101281301 is not exists' if City.find_by_weather_com_cn_code_and_name('101281301','清远').nil?
    puts '云浮--101281401 is not exists' if City.find_by_weather_com_cn_code_and_name('101281401','云浮').nil?
    puts '潮州--101281501 is not exists' if City.find_by_weather_com_cn_code_and_name('101281501','潮州').nil?
    puts '东莞--101281601 is not exists' if City.find_by_weather_com_cn_code_and_name('101281601','东莞').nil?
    puts '中山--101281701 is not exists' if City.find_by_weather_com_cn_code_and_name('101281701','中山').nil?
    puts '阳江--101281801 is not exists' if City.find_by_weather_com_cn_code_and_name('101281801','阳江').nil?
    puts '揭阳--101281901 is not exists' if City.find_by_weather_com_cn_code_and_name('101281901','揭阳').nil?
    puts '茂名--101282001 is not exists' if City.find_by_weather_com_cn_code_and_name('101282001','茂名').nil?
    puts '汕尾--101282101 is not exists' if City.find_by_weather_com_cn_code_and_name('101282101','汕尾').nil?
    puts '东沙岛--101282105 is not exists' if City.find_by_weather_com_cn_code_and_name('101282105','东沙岛').nil?
    ## 广西
    puts '南宁--101300101 is not exists' if City.find_by_weather_com_cn_code_and_name('101300101','南宁').nil?
    puts '崇左--101300201 is not exists' if City.find_by_weather_com_cn_code_and_name('101300201','崇左').nil?
    puts '柳州--101300301 is not exists' if City.find_by_weather_com_cn_code_and_name('101300301','柳州').nil?
    puts '来宾--101300401 is not exists' if City.find_by_weather_com_cn_code_and_name('101300401','来宾').nil?
    puts '桂林--101300501 is not exists' if City.find_by_weather_com_cn_code_and_name('101300501','桂林').nil?
    puts '梧州--101300601 is not exists' if City.find_by_weather_com_cn_code_and_name('101300601','梧州').nil?
    puts '贺州--101300701 is not exists' if City.find_by_weather_com_cn_code_and_name('101300701','贺州').nil?
    puts '贵港--101300801 is not exists' if City.find_by_weather_com_cn_code_and_name('101300801','贵港').nil?
    puts '玉林--101300901 is not exists' if City.find_by_weather_com_cn_code_and_name('101300901','玉林').nil?
    puts '百色--101301001 is not exists' if City.find_by_weather_com_cn_code_and_name('101301001','百色').nil?
    puts '钦州--101301101 is not exists' if City.find_by_weather_com_cn_code_and_name('101301101','钦州').nil?
    puts '河池--101301201 is not exists' if City.find_by_weather_com_cn_code_and_name('101301201','河池').nil?
    puts '北海--101301301 is not exists' if City.find_by_weather_com_cn_code_and_name('101301301','北海').nil?
    puts '防城港--101301401 is not exists' if City.find_by_weather_com_cn_code_and_name('101301401','防城港').nil?
    ## 贵州
    puts '贵阳--101260101 is not exists' if City.find_by_weather_com_cn_code_and_name('101260101','贵阳').nil?
    puts '遵义--101260201 is not exists' if City.find_by_weather_com_cn_code_and_name('101260201','遵义').nil?
    puts '安顺--101260301 is not exists' if City.find_by_weather_com_cn_code_and_name('101260301','安顺').nil?
    puts '都匀--101260401 is not exists' if City.find_by_weather_com_cn_code_and_name('101260401','都匀').nil?
    puts '凯里--101260501 is not exists' if City.find_by_weather_com_cn_code_and_name('101260501','凯里').nil?
    puts '铜仁--101260601 is not exists' if City.find_by_weather_com_cn_code_and_name('101260601','铜仁').nil?
    puts '毕节--101260701 is not exists' if City.find_by_weather_com_cn_code_and_name('101260701','毕节').nil?
    puts '六盘水--101260801 is not exists' if City.find_by_weather_com_cn_code_and_name('101260801','六盘水').nil?
    puts '黔西--101260901 is not exists' if City.find_by_weather_com_cn_code_and_name('101260901','黔西').nil?
    ## 海南
    puts '海口--101310101 is not exists' if City.find_by_weather_com_cn_code_and_name('101310101','海口').nil?
    puts '琼山--101310102 is not exists' if City.find_by_weather_com_cn_code_and_name('101310102','琼山').nil?
    puts '三亚--101310201 is not exists' if City.find_by_weather_com_cn_code_and_name('101310201','三亚').nil?
    puts '东方--101310202 is not exists' if City.find_by_weather_com_cn_code_and_name('101310202','东方').nil?
    puts '临高--101310203 is not exists' if City.find_by_weather_com_cn_code_and_name('101310203','临高').nil?
    puts '澄迈--101310204 is not exists' if City.find_by_weather_com_cn_code_and_name('101310204','澄迈').nil?
    puts '儋州--101310205 is not exists' if City.find_by_weather_com_cn_code_and_name('101310205','儋州').nil?
    puts '昌江--101310206 is not exists' if City.find_by_weather_com_cn_code_and_name('101310206','昌江').nil?
    puts '白沙--101310207 is not exists' if City.find_by_weather_com_cn_code_and_name('101310207','白沙').nil?
    puts '琼中--101310208 is not exists' if City.find_by_weather_com_cn_code_and_name('101310208','琼中').nil?
    puts '定安--101310209 is not exists' if City.find_by_weather_com_cn_code_and_name('101310209','定安').nil?
    puts '屯昌--101310210 is not exists' if City.find_by_weather_com_cn_code_and_name('101310210','屯昌').nil?
    puts '琼海--101310211 is not exists' if City.find_by_weather_com_cn_code_and_name('101310211','琼海').nil?
    puts '文昌--101310212 is not exists' if City.find_by_weather_com_cn_code_and_name('101310212','文昌').nil?
    puts '清兰--101310213 is not exists' if City.find_by_weather_com_cn_code_and_name('101310213','清兰').nil?
    puts '保亭--101310214 is not exists' if City.find_by_weather_com_cn_code_and_name('101310214','保亭').nil?
    puts '万宁--101310215 is not exists' if City.find_by_weather_com_cn_code_and_name('101310215','万宁').nil?
    puts '陵水--101310216 is not exists' if City.find_by_weather_com_cn_code_and_name('101310216','陵水').nil?
    puts '西沙--101310217 is not exists' if City.find_by_weather_com_cn_code_and_name('101310217','西沙').nil?
    puts '珊瑚岛--101310218 is not exists' if City.find_by_weather_com_cn_code_and_name('101310218','珊瑚岛').nil?
    puts '永署礁--101310219 is not exists' if City.find_by_weather_com_cn_code_and_name('101310219','永署礁').nil?
    puts '南沙岛--101310220 is not exists' if City.find_by_weather_com_cn_code_and_name('101310220','南沙岛').nil?
    puts '乐东--101310221 is not exists' if City.find_by_weather_com_cn_code_and_name('101310221','乐东').nil?
    puts '通什--101310222 is not exists' if City.find_by_weather_com_cn_code_and_name('101310222','通什').nil?
    ## 河北
    puts '石家庄--101090101 is not exists' if City.find_by_weather_com_cn_code_and_name('101090101','石家庄').nil?
    puts '保定--101090201 is not exists' if City.find_by_weather_com_cn_code_and_name('101090201','保定').nil?
    puts '张家口--101090301 is not exists' if City.find_by_weather_com_cn_code_and_name('101090301','张家口').nil?
    puts '承德市--101090401 is not exists' if City.find_by_weather_com_cn_code_and_name('101090401','承德市').nil?
    puts '唐山--101090501 is not exists' if City.find_by_weather_com_cn_code_and_name('101090501','唐山').nil?
    puts '廊坊--101090601 is not exists' if City.find_by_weather_com_cn_code_and_name('101090601','廊坊').nil?
    puts '沧州--101090701 is not exists' if City.find_by_weather_com_cn_code_and_name('101090701','沧州').nil?
    puts '衡水--101090801 is not exists' if City.find_by_weather_com_cn_code_and_name('101090801','衡水').nil?
    puts '邢台--101090901 is not exists' if City.find_by_weather_com_cn_code_and_name('101090901','邢台').nil?
    puts '邯郸--101091001 is not exists' if City.find_by_weather_com_cn_code_and_name('101091001','邯郸').nil?
    puts '秦皇岛--101091101 is not exists' if City.find_by_weather_com_cn_code_and_name('101091101','秦皇岛').nil?
    ## 河南
    puts '郑州--101180101 is not exists' if City.find_by_weather_com_cn_code_and_name('101180101','郑州').nil?
    puts '安阳--101180201 is not exists' if City.find_by_weather_com_cn_code_and_name('101180201','安阳').nil?
    puts '新乡--101180301 is not exists' if City.find_by_weather_com_cn_code_and_name('101180301','新乡').nil?
    puts '许昌--101180401 is not exists' if City.find_by_weather_com_cn_code_and_name('101180401','许昌').nil?
    puts '平顶山--101180501 is not exists' if City.find_by_weather_com_cn_code_and_name('101180501','平顶山').nil?
    puts '信阳--101180601 is not exists' if City.find_by_weather_com_cn_code_and_name('101180601','信阳').nil?
    puts '南阳--101180701 is not exists' if City.find_by_weather_com_cn_code_and_name('101180701','南阳').nil?
    puts '开封--101180801 is not exists' if City.find_by_weather_com_cn_code_and_name('101180801','开封').nil?
    puts '洛阳--101180901 is not exists' if City.find_by_weather_com_cn_code_and_name('101180901','洛阳').nil?
    puts '商丘--101181001 is not exists' if City.find_by_weather_com_cn_code_and_name('101181001','商丘').nil?
    puts '焦作--101181101 is not exists' if City.find_by_weather_com_cn_code_and_name('101181101','焦作').nil?
    puts '鹤壁--101181201 is not exists' if City.find_by_weather_com_cn_code_and_name('101181201','鹤壁').nil?
    puts '濮阳--101181301 is not exists' if City.find_by_weather_com_cn_code_and_name('101181301','濮阳').nil?
    puts '周口--101181401 is not exists' if City.find_by_weather_com_cn_code_and_name('101181401','周口').nil?
    puts '漯河--101181501 is not exists' if City.find_by_weather_com_cn_code_and_name('101181501','漯河').nil?
    puts '驻马店--101181601 is not exists' if City.find_by_weather_com_cn_code_and_name('101181601','驻马店').nil?
    puts '三门峡--101181701 is not exists' if City.find_by_weather_com_cn_code_and_name('101181701','三门峡').nil?
    puts '济源--101181801 is not exists' if City.find_by_weather_com_cn_code_and_name('101181801','济源').nil?
    ## 黑龙江
    puts '哈尔滨--101050101 is not exists' if City.find_by_weather_com_cn_code_and_name('101050101','哈尔滨').nil?
    puts '齐齐哈尔--101050201 is not exists' if City.find_by_weather_com_cn_code_and_name('101050201','齐齐哈尔').nil?
    puts '牡丹江--101050301 is not exists' if City.find_by_weather_com_cn_code_and_name('101050301','牡丹江').nil?
    puts '佳木斯--101050401 is not exists' if City.find_by_weather_com_cn_code_and_name('101050401','佳木斯').nil?
    puts '绥化--101050501 is not exists' if City.find_by_weather_com_cn_code_and_name('101050501','绥化').nil?
    puts '黑河--101050601 is not exists' if City.find_by_weather_com_cn_code_and_name('101050601','黑河').nil?
    puts '大兴安岭--101050701 is not exists' if City.find_by_weather_com_cn_code_and_name('101050701','大兴安岭').nil?
    puts '伊春--101050801 is not exists' if City.find_by_weather_com_cn_code_and_name('101050801','伊春').nil?
    puts '大庆--101050901 is not exists' if City.find_by_weather_com_cn_code_and_name('101050901','大庆').nil?
    puts '七台河--101051002 is not exists' if City.find_by_weather_com_cn_code_and_name('101051002','七台河').nil?
    puts '鸡西--101051101 is not exists' if City.find_by_weather_com_cn_code_and_name('101051101','鸡西').nil?
    puts '鹤岗--101051201 is not exists' if City.find_by_weather_com_cn_code_and_name('101051201','鹤岗').nil?
    puts '双鸭山--101051301 is not exists' if City.find_by_weather_com_cn_code_and_name('101051301','双鸭山').nil?
    ## 湖北
    puts '武汉--101200101 is not exists' if City.find_by_weather_com_cn_code_and_name('101200101','武汉').nil?
    puts '襄樊--101200201 is not exists' if City.find_by_weather_com_cn_code_and_name('101200201','襄樊').nil?
    puts '鄂州--101200301 is not exists' if City.find_by_weather_com_cn_code_and_name('101200301','鄂州').nil?
    puts '孝感--101200401 is not exists' if City.find_by_weather_com_cn_code_and_name('101200401','孝感').nil?
    puts '黄冈--101200501 is not exists' if City.find_by_weather_com_cn_code_and_name('101200501','黄冈').nil?
    puts '黄石--101200601 is not exists' if City.find_by_weather_com_cn_code_and_name('101200601','黄石').nil?
    puts '咸宁--101200701 is not exists' if City.find_by_weather_com_cn_code_and_name('101200701','咸宁').nil?
    puts '荆州--101200801 is not exists' if City.find_by_weather_com_cn_code_and_name('101200801','荆州').nil?
    puts '宜昌--101200901 is not exists' if City.find_by_weather_com_cn_code_and_name('101200901','宜昌').nil?
    puts '恩施--101201001 is not exists' if City.find_by_weather_com_cn_code_and_name('101201001','恩施').nil?
    puts '十堰--101201101 is not exists' if City.find_by_weather_com_cn_code_and_name('101201101','十堰').nil?
    puts '神农架--101201201 is not exists' if City.find_by_weather_com_cn_code_and_name('101201201','神农架').nil?
    puts '随州--101201301 is not exists' if City.find_by_weather_com_cn_code_and_name('101201301','随州').nil?
    puts '荆门--101201401 is not exists' if City.find_by_weather_com_cn_code_and_name('101201401','荆门').nil?
    puts '天门--101201501 is not exists' if City.find_by_weather_com_cn_code_and_name('101201501','天门').nil?
    puts '仙桃--101201601 is not exists' if City.find_by_weather_com_cn_code_and_name('101201601','仙桃').nil?
    puts '潜江--101201701 is not exists' if City.find_by_weather_com_cn_code_and_name('101201701','潜江').nil?
    ## 湖南
    puts '长沙--101250101 is not exists' if City.find_by_weather_com_cn_code_and_name('101250101','长沙').nil?
    puts '湘潭--101250201 is not exists' if City.find_by_weather_com_cn_code_and_name('101250201','湘潭').nil?
    puts '株洲--101250301 is not exists' if City.find_by_weather_com_cn_code_and_name('101250301','株洲').nil?
    puts '衡阳--101250401 is not exists' if City.find_by_weather_com_cn_code_and_name('101250401','衡阳').nil?
    puts '郴州--101250501 is not exists' if City.find_by_weather_com_cn_code_and_name('101250501','郴州').nil?
    puts '常德--101250601 is not exists' if City.find_by_weather_com_cn_code_and_name('101250601','常德').nil?
    puts '益阳--101250701 is not exists' if City.find_by_weather_com_cn_code_and_name('101250701','益阳').nil?
    puts '娄底--101250801 is not exists' if City.find_by_weather_com_cn_code_and_name('101250801','娄底').nil?
    puts '邵阳--101250901 is not exists' if City.find_by_weather_com_cn_code_and_name('101250901','邵阳').nil?
    puts '岳阳--101251001 is not exists' if City.find_by_weather_com_cn_code_and_name('101251001','岳阳').nil?
    puts '张家界--101251101 is not exists' if City.find_by_weather_com_cn_code_and_name('101251101','张家界').nil?
    puts '怀化--101251201 is not exists' if City.find_by_weather_com_cn_code_and_name('101251201','怀化').nil?
    puts '黔阳--101251301 is not exists' if City.find_by_weather_com_cn_code_and_name('101251301','黔阳').nil?
    puts '永州--101251401 is not exists' if City.find_by_weather_com_cn_code_and_name('101251401','永州').nil?
    puts '吉首--101251501 is not exists' if City.find_by_weather_com_cn_code_and_name('101251501','吉首').nil?
    ## 吉林
    puts '长春--101060101 is not exists' if City.find_by_weather_com_cn_code_and_name('101060101','长春').nil?
    puts '吉林--101060201 is not exists' if City.find_by_weather_com_cn_code_and_name('101060201','吉林').nil?
    puts '延吉--101060301 is not exists' if City.find_by_weather_com_cn_code_and_name('101060301','延吉').nil?
    puts '四平--101060401 is not exists' if City.find_by_weather_com_cn_code_and_name('101060401','四平').nil?
    puts '通化--101060501 is not exists' if City.find_by_weather_com_cn_code_and_name('101060501','通化').nil?
    puts '白城--101060601 is not exists' if City.find_by_weather_com_cn_code_and_name('101060601','白城').nil?
    puts '辽源--101060701 is not exists' if City.find_by_weather_com_cn_code_and_name('101060701','辽源').nil?
    puts '松原--101060801 is not exists' if City.find_by_weather_com_cn_code_and_name('101060801','松原').nil?
    puts '白山--101060901 is not exists' if City.find_by_weather_com_cn_code_and_name('101060901','白山').nil?
    ## 江苏
    puts '南京--101190101 is not exists' if City.find_by_weather_com_cn_code_and_name('101190101','南京').nil?
    puts '无锡--101190201 is not exists' if City.find_by_weather_com_cn_code_and_name('101190201','无锡').nil?
    puts '镇江--101190301 is not exists' if City.find_by_weather_com_cn_code_and_name('101190301','镇江').nil?
    puts '苏州--101190401 is not exists' if City.find_by_weather_com_cn_code_and_name('101190401','苏州').nil?
    puts '南通--101190501 is not exists' if City.find_by_weather_com_cn_code_and_name('101190501','南通').nil?
    puts '扬州--101190601 is not exists' if City.find_by_weather_com_cn_code_and_name('101190601','扬州').nil?
    puts '盐城--101190701 is not exists' if City.find_by_weather_com_cn_code_and_name('101190701','盐城').nil?
    puts '徐州--101190801 is not exists' if City.find_by_weather_com_cn_code_and_name('101190801','徐州').nil?
    puts '淮安--101190901 is not exists' if City.find_by_weather_com_cn_code_and_name('101190901','淮安').nil?
    puts '连云港--101191001 is not exists' if City.find_by_weather_com_cn_code_and_name('101191001','连云港').nil?
    puts '常州--101191101 is not exists' if City.find_by_weather_com_cn_code_and_name('101191101','常州').nil?
    puts '泰州--101191201 is not exists' if City.find_by_weather_com_cn_code_and_name('101191201','泰州').nil?
    puts '宿迁--101191301 is not exists' if City.find_by_weather_com_cn_code_and_name('101191301','宿迁').nil?
    ## 江西
    puts '南昌--101240101 is not exists' if City.find_by_weather_com_cn_code_and_name('101240101','南昌').nil?
    puts '九江--101240201 is not exists' if City.find_by_weather_com_cn_code_and_name('101240201','九江').nil?
    puts '上饶--101240301 is not exists' if City.find_by_weather_com_cn_code_and_name('101240301','上饶').nil?
    puts '抚州--101240401 is not exists' if City.find_by_weather_com_cn_code_and_name('101240401','抚州').nil?
    puts '宜春--101240501 is not exists' if City.find_by_weather_com_cn_code_and_name('101240501','宜春').nil?
    puts '吉安--101240601 is not exists' if City.find_by_weather_com_cn_code_and_name('101240601','吉安').nil?
    puts '赣州--101240701 is not exists' if City.find_by_weather_com_cn_code_and_name('101240701','赣州').nil?
    puts '景德镇--101240801 is not exists' if City.find_by_weather_com_cn_code_and_name('101240801','景德镇').nil?
    puts '萍乡--101240901 is not exists' if City.find_by_weather_com_cn_code_and_name('101240901','萍乡').nil?
    puts '新余--101241001 is not exists' if City.find_by_weather_com_cn_code_and_name('101241001','新余').nil?
    puts '鹰潭--101241101 is not exists' if City.find_by_weather_com_cn_code_and_name('101241101','鹰潭').nil?
    ## 辽宁
    puts '沈阳--101070101 is not exists' if City.find_by_weather_com_cn_code_and_name('101070101','沈阳').nil?
    puts '大连--101070201 is not exists' if City.find_by_weather_com_cn_code_and_name('101070201','大连').nil?
    puts '鞍山--101070301 is not exists' if City.find_by_weather_com_cn_code_and_name('101070301','鞍山').nil?
    puts '抚顺--101070401 is not exists' if City.find_by_weather_com_cn_code_and_name('101070401','抚顺').nil?
    puts '本溪--101070501 is not exists' if City.find_by_weather_com_cn_code_and_name('101070501','本溪').nil?
    puts '丹东--101070601 is not exists' if City.find_by_weather_com_cn_code_and_name('101070601','丹东').nil?
    puts '锦州--101070701 is not exists' if City.find_by_weather_com_cn_code_and_name('101070701','锦州').nil?
    puts '营口--101070801 is not exists' if City.find_by_weather_com_cn_code_and_name('101070801','营口').nil?
    puts '阜新--101070901 is not exists' if City.find_by_weather_com_cn_code_and_name('101070901','阜新').nil?
    puts '辽阳--101071001 is not exists' if City.find_by_weather_com_cn_code_and_name('101071001','辽阳').nil?
    puts '铁岭--101071101 is not exists' if City.find_by_weather_com_cn_code_and_name('101071101','铁岭').nil?
    puts '朝阳--101071201 is not exists' if City.find_by_weather_com_cn_code_and_name('101071201','朝阳').nil?
    puts '盘锦--101071301 is not exists' if City.find_by_weather_com_cn_code_and_name('101071301','盘锦').nil?
    puts '葫芦岛--101071401 is not exists' if City.find_by_weather_com_cn_code_and_name('101071401','葫芦岛').nil?
    ## 内蒙古
    puts '呼和浩特--101080101 is not exists' if City.find_by_weather_com_cn_code_and_name('101080101','呼和浩特').nil?
    puts '包头--101080201 is not exists' if City.find_by_weather_com_cn_code_and_name('101080201','包头').nil?
    puts '乌海--101080301 is not exists' if City.find_by_weather_com_cn_code_and_name('101080301','乌海').nil?
    puts '集宁--101080401 is not exists' if City.find_by_weather_com_cn_code_and_name('101080401','集宁').nil?
    puts '通辽--101080501 is not exists' if City.find_by_weather_com_cn_code_and_name('101080501','通辽').nil?
    puts '赤峰--101080601 is not exists' if City.find_by_weather_com_cn_code_and_name('101080601','赤峰').nil?
    puts '鄂尔多斯--101080701 is not exists' if City.find_by_weather_com_cn_code_and_name('101080701','鄂尔多斯').nil?
    puts '临河--101080801 is not exists' if City.find_by_weather_com_cn_code_and_name('101080801','临河').nil?
    puts '锡林浩特--101080901 is not exists' if City.find_by_weather_com_cn_code_and_name('101080901','锡林浩特').nil?
    puts '呼伦贝尔--101081000 is not exists' if City.find_by_weather_com_cn_code_and_name('101081000','呼伦贝尔').nil?
    puts '乌兰浩特--101081101 is not exists' if City.find_by_weather_com_cn_code_and_name('101081101','乌兰浩特').nil?
    puts '阿拉善左旗--101081201 is not exists' if City.find_by_weather_com_cn_code_and_name('101081201','阿拉善左旗').nil?
    ## 宁夏
    puts '银川--101170101 is not exists' if City.find_by_weather_com_cn_code_and_name('101170101','银川').nil?
    puts '石嘴山--101170201 is not exists' if City.find_by_weather_com_cn_code_and_name('101170201','石嘴山').nil?
    puts '吴忠--101170301 is not exists' if City.find_by_weather_com_cn_code_and_name('101170301','吴忠').nil?
    puts '固原--101170401 is not exists' if City.find_by_weather_com_cn_code_and_name('101170401','固原').nil?
    puts '中卫--101170501 is not exists' if City.find_by_weather_com_cn_code_and_name('101170501','中卫').nil?
    ## 青海
    puts '西宁--101150101 is not exists' if City.find_by_weather_com_cn_code_and_name('101150101','西宁').nil?
    puts '海东--101150201 is not exists' if City.find_by_weather_com_cn_code_and_name('101150201','海东').nil?
    puts '黄南--101150301 is not exists' if City.find_by_weather_com_cn_code_and_name('101150301','黄南').nil?
    puts '海南--101150401 is not exists' if City.find_by_weather_com_cn_code_and_name('101150401','海南').nil?
    puts '果洛--101150501 is not exists' if City.find_by_weather_com_cn_code_and_name('101150501','果洛').nil?
    puts '玉树--101150601 is not exists' if City.find_by_weather_com_cn_code_and_name('101150601','玉树').nil?
    puts '海西--101150701 is not exists' if City.find_by_weather_com_cn_code_and_name('101150701','海西').nil?
    puts '海北--101150801 is not exists' if City.find_by_weather_com_cn_code_and_name('101150801','海北').nil?
    ## 山东
    puts '济南--101120101 is not exists' if City.find_by_weather_com_cn_code_and_name('101120101','济南').nil?
    puts '青岛--101120201 is not exists' if City.find_by_weather_com_cn_code_and_name('101120201','青岛').nil?
    puts '淄博--101120301 is not exists' if City.find_by_weather_com_cn_code_and_name('101120301','淄博').nil?
    puts '德州--101120401 is not exists' if City.find_by_weather_com_cn_code_and_name('101120401','德州').nil?
    puts '烟台--101120501 is not exists' if City.find_by_weather_com_cn_code_and_name('101120501','烟台').nil?
    puts '潍坊--101120601 is not exists' if City.find_by_weather_com_cn_code_and_name('101120601','潍坊').nil?
    puts '济宁--101120701 is not exists' if City.find_by_weather_com_cn_code_and_name('101120701','济宁').nil?
    puts '泰安--101120801 is not exists' if City.find_by_weather_com_cn_code_and_name('101120801','泰安').nil?
    puts '临沂--101120901 is not exists' if City.find_by_weather_com_cn_code_and_name('101120901','临沂').nil?
    puts '菏泽--101121001 is not exists' if City.find_by_weather_com_cn_code_and_name('101121001','菏泽').nil?
    puts '滨州--101121101 is not exists' if City.find_by_weather_com_cn_code_and_name('101121101','滨州').nil?
    puts '东营--101121201 is not exists' if City.find_by_weather_com_cn_code_and_name('101121201','东营').nil?
    puts '威海--101121301 is not exists' if City.find_by_weather_com_cn_code_and_name('101121301','威海').nil?
    puts '枣庄--101121401 is not exists' if City.find_by_weather_com_cn_code_and_name('101121401','枣庄').nil?
    puts '日照--101121501 is not exists' if City.find_by_weather_com_cn_code_and_name('101121501','日照').nil?
    puts '莱芜--101121601 is not exists' if City.find_by_weather_com_cn_code_and_name('101121601','莱芜').nil?
    puts '聊城--101121701 is not exists' if City.find_by_weather_com_cn_code_and_name('101121701','聊城').nil?
    ## 山西
    puts '太原--101100101 is not exists' if City.find_by_weather_com_cn_code_and_name('101100101','太原').nil?
    puts '大同--101100201 is not exists' if City.find_by_weather_com_cn_code_and_name('101100201','大同').nil?
    puts '阳泉--101100301 is not exists' if City.find_by_weather_com_cn_code_and_name('101100301','阳泉').nil?
    puts '晋中--101100401 is not exists' if City.find_by_weather_com_cn_code_and_name('101100401','晋中').nil?
    puts '长治--101100501 is not exists' if City.find_by_weather_com_cn_code_and_name('101100501','长治').nil?
    puts '晋城--101100601 is not exists' if City.find_by_weather_com_cn_code_and_name('101100601','晋城').nil?
    puts '临汾--101100701 is not exists' if City.find_by_weather_com_cn_code_and_name('101100701','临汾').nil?
    puts '运城--101100801 is not exists' if City.find_by_weather_com_cn_code_and_name('101100801','运城').nil?
    puts '朔州--101100901 is not exists' if City.find_by_weather_com_cn_code_and_name('101100901','朔州').nil?
    puts '忻州--101101001 is not exists' if City.find_by_weather_com_cn_code_and_name('101101001','忻州').nil?
    puts '吕梁--101101100 is not exists' if City.find_by_weather_com_cn_code_and_name('101101100','吕梁').nil?
    ## 陕西
    puts '西安--101110101 is not exists' if City.find_by_weather_com_cn_code_and_name('101110101','西安').nil?
    puts '咸阳--101110200 is not exists' if City.find_by_weather_com_cn_code_and_name('101110200','咸阳').nil?
    puts '延安--101110300 is not exists' if City.find_by_weather_com_cn_code_and_name('101110300','延安').nil?
    puts '榆林--101110401 is not exists' if City.find_by_weather_com_cn_code_and_name('101110401','榆林').nil?
    puts '渭南--101110501 is not exists' if City.find_by_weather_com_cn_code_and_name('101110501','渭南').nil?
    puts '商洛--101110601 is not exists' if City.find_by_weather_com_cn_code_and_name('101110601','商洛').nil?
    puts '安康--101110701 is not exists' if City.find_by_weather_com_cn_code_and_name('101110701','安康').nil?
    puts '汉中--101110801 is not exists' if City.find_by_weather_com_cn_code_and_name('101110801','汉中').nil?
    puts '宝鸡--101110901 is not exists' if City.find_by_weather_com_cn_code_and_name('101110901','宝鸡').nil?
    puts '铜川--101111001 is not exists' if City.find_by_weather_com_cn_code_and_name('101111001','铜川').nil?
    ## 四川
    puts '成都--101270101 is not exists' if City.find_by_weather_com_cn_code_and_name('101270101','成都').nil?
    puts '攀枝花--101270201 is not exists' if City.find_by_weather_com_cn_code_and_name('101270201','攀枝花').nil?
    puts '自贡--101270301 is not exists' if City.find_by_weather_com_cn_code_and_name('101270301','自贡').nil?
    puts '绵阳--101270401 is not exists' if City.find_by_weather_com_cn_code_and_name('101270401','绵阳').nil?
    puts '南充--101270501 is not exists' if City.find_by_weather_com_cn_code_and_name('101270501','南充').nil?
    puts '达州--101270601 is not exists' if City.find_by_weather_com_cn_code_and_name('101270601','达州').nil?
    puts '遂宁--101270701 is not exists' if City.find_by_weather_com_cn_code_and_name('101270701','遂宁').nil?
    puts '广安--101270801 is not exists' if City.find_by_weather_com_cn_code_and_name('101270801','广安').nil?
    puts '巴中--101270901 is not exists' if City.find_by_weather_com_cn_code_and_name('101270901','巴中').nil?
    puts '泸州--101271001 is not exists' if City.find_by_weather_com_cn_code_and_name('101271001','泸州').nil?
    puts '宜宾--101271101 is not exists' if City.find_by_weather_com_cn_code_and_name('101271101','宜宾').nil?
    puts '内江--101271201 is not exists' if City.find_by_weather_com_cn_code_and_name('101271201','内江').nil?
    puts '资阳--101271301 is not exists' if City.find_by_weather_com_cn_code_and_name('101271301','资阳').nil?
    puts '乐山--101271401 is not exists' if City.find_by_weather_com_cn_code_and_name('101271401','乐山').nil?
    puts '眉山--101271501 is not exists' if City.find_by_weather_com_cn_code_and_name('101271501','眉山').nil?
    puts '凉山--101271601 is not exists' if City.find_by_weather_com_cn_code_and_name('101271601','凉山').nil?
    puts '雅安--101271701 is not exists' if City.find_by_weather_com_cn_code_and_name('101271701','雅安').nil?
    puts '甘孜--101271801 is not exists' if City.find_by_weather_com_cn_code_and_name('101271801','甘孜').nil?
    puts '阿坝--101271901 is not exists' if City.find_by_weather_com_cn_code_and_name('101271901','阿坝').nil?
    puts '德阳--101272001 is not exists' if City.find_by_weather_com_cn_code_and_name('101272001','德阳').nil?
    puts '广元--101272101 is not exists' if City.find_by_weather_com_cn_code_and_name('101272101','广元').nil?
    ## 台湾
    puts '台北县--101340101 is not exists' if City.find_by_weather_com_cn_code_and_name('101340101','台北县').nil?
    puts '高雄--101340201 is not exists' if City.find_by_weather_com_cn_code_and_name('101340201','高雄').nil?
    puts '台南--101340301 is not exists' if City.find_by_weather_com_cn_code_and_name('101340301','台南').nil?
    puts '台中--101340401 is not exists' if City.find_by_weather_com_cn_code_and_name('101340401','台中').nil?
    puts '桃园--101340501 is not exists' if City.find_by_weather_com_cn_code_and_name('101340501','桃园').nil?
    puts '新竹县--101340601 is not exists' if City.find_by_weather_com_cn_code_and_name('101340601','新竹县').nil?
    puts '宜兰--101340701 is not exists' if City.find_by_weather_com_cn_code_and_name('101340701','宜兰').nil?
    puts '马公--101340801 is not exists' if City.find_by_weather_com_cn_code_and_name('101340801','马公').nil?
    puts '嘉义--101340901 is not exists' if City.find_by_weather_com_cn_code_and_name('101340901','嘉义').nil?
    puts '花莲--101341001 is not exists' if City.find_by_weather_com_cn_code_and_name('101341001','花莲').nil?
    puts '台东--101341101 is not exists' if City.find_by_weather_com_cn_code_and_name('101341101','台东').nil?
    puts '彭佳屿--101341201 is not exists' if City.find_by_weather_com_cn_code_and_name('101341201','彭佳屿').nil?
    ## 西藏
    puts '拉萨--101140101 is not exists' if City.find_by_weather_com_cn_code_and_name('101140101','拉萨').nil?
    puts '日喀则--101140201 is not exists' if City.find_by_weather_com_cn_code_and_name('101140201','日喀则').nil?
    puts '山南--101140301 is not exists' if City.find_by_weather_com_cn_code_and_name('101140301','山南').nil?
    puts '林芝--101140401 is not exists' if City.find_by_weather_com_cn_code_and_name('101140401','林芝').nil?
    puts '昌都--101140501 is not exists' if City.find_by_weather_com_cn_code_and_name('101140501','昌都').nil?
    puts '那曲--101140601 is not exists' if City.find_by_weather_com_cn_code_and_name('101140601','那曲').nil?
    puts '阿里--101140701 is not exists' if City.find_by_weather_com_cn_code_and_name('101140701','阿里').nil?
    ## 新疆
    puts '乌鲁木齐--101130101 is not exists' if City.find_by_weather_com_cn_code_and_name('101130101','乌鲁木齐').nil?
    puts '克拉玛依--101130201 is not exists' if City.find_by_weather_com_cn_code_and_name('101130201','克拉玛依').nil?
    puts '石河子--101130301 is not exists' if City.find_by_weather_com_cn_code_and_name('101130301','石河子').nil?
    puts '昌吉--101130401 is not exists' if City.find_by_weather_com_cn_code_and_name('101130401','昌吉').nil?
    puts '吐鲁番--101130501 is not exists' if City.find_by_weather_com_cn_code_and_name('101130501','吐鲁番').nil?
    puts '库尔勒--101130601 is not exists' if City.find_by_weather_com_cn_code_and_name('101130601','库尔勒').nil?
    puts '阿拉尔--101130701 is not exists' if City.find_by_weather_com_cn_code_and_name('101130701','阿拉尔').nil?
    puts '阿克苏--101130801 is not exists' if City.find_by_weather_com_cn_code_and_name('101130801','阿克苏').nil?
    puts '喀什--101130901 is not exists' if City.find_by_weather_com_cn_code_and_name('101130901','喀什').nil?
    puts '伊宁--101131001 is not exists' if City.find_by_weather_com_cn_code_and_name('101131001','伊宁').nil?
    puts '塔城--101131101 is not exists' if City.find_by_weather_com_cn_code_and_name('101131101','塔城').nil?
    puts '哈密--101131201 is not exists' if City.find_by_weather_com_cn_code_and_name('101131201','哈密').nil?
    puts '和田--101131301 is not exists' if City.find_by_weather_com_cn_code_and_name('101131301','和田').nil?
    puts '阿勒泰--101131401 is not exists' if City.find_by_weather_com_cn_code_and_name('101131401','阿勒泰').nil?
    puts '阿图什--101131501 is not exists' if City.find_by_weather_com_cn_code_and_name('101131501','阿图什').nil?
    puts '博乐--1011301601 is not exists' if City.find_by_weather_com_cn_code_and_name('1011301601','博乐').nil?
    ## 云南
    puts '昆明--101290101 is not exists' if City.find_by_weather_com_cn_code_and_name('101290101','昆明').nil?
    puts '大理--101290201 is not exists' if City.find_by_weather_com_cn_code_and_name('101290201','大理').nil?
    puts '红河--101290301 is not exists' if City.find_by_weather_com_cn_code_and_name('101290301','红河').nil?
    puts '曲靖--101290401 is not exists' if City.find_by_weather_com_cn_code_and_name('101290401','曲靖').nil?
    puts '保山--101290501 is not exists' if City.find_by_weather_com_cn_code_and_name('101290501','保山').nil?
    puts '文山--101290601 is not exists' if City.find_by_weather_com_cn_code_and_name('101290601','文山').nil?
    puts '玉溪--101290701 is not exists' if City.find_by_weather_com_cn_code_and_name('101290701','玉溪').nil?
    puts '楚雄--101290801 is not exists' if City.find_by_weather_com_cn_code_and_name('101290801','楚雄').nil?
    puts '普洱--101290901 is not exists' if City.find_by_weather_com_cn_code_and_name('101290901','普洱').nil?
    puts '昭通--101291001 is not exists' if City.find_by_weather_com_cn_code_and_name('101291001','昭通').nil?
    puts '临沧--101291101 is not exists' if City.find_by_weather_com_cn_code_and_name('101291101','临沧').nil?
    puts '怒江--101291201 is not exists' if City.find_by_weather_com_cn_code_and_name('101291201','怒江').nil?
    puts '中甸--101291301 is not exists' if City.find_by_weather_com_cn_code_and_name('101291301','中甸').nil?
    puts '丽江--101291401 is not exists' if City.find_by_weather_com_cn_code_and_name('101291401','丽江').nil?
    puts '德宏--101291501 is not exists' if City.find_by_weather_com_cn_code_and_name('101291501','德宏').nil?
    puts '景洪--101291601 is not exists' if City.find_by_weather_com_cn_code_and_name('101291601','景洪').nil?
    ## 浙江
    puts '杭州--101210101 is not exists' if City.find_by_weather_com_cn_code_and_name('101210101','杭州').nil?
    puts '湖州--101210201 is not exists' if City.find_by_weather_com_cn_code_and_name('101210201','湖州').nil?
    puts '嘉兴--101210301 is not exists' if City.find_by_weather_com_cn_code_and_name('101210301','嘉兴').nil?
    puts '宁波--101210401 is not exists' if City.find_by_weather_com_cn_code_and_name('101210401','宁波').nil?
    puts '绍兴--101210501 is not exists' if City.find_by_weather_com_cn_code_and_name('101210501','绍兴').nil?
    puts '台州--101210601 is not exists' if City.find_by_weather_com_cn_code_and_name('101210601','台州').nil?
    puts '温州--101210701 is not exists' if City.find_by_weather_com_cn_code_and_name('101210701','温州').nil?
    puts '丽水--101210801 is not exists' if City.find_by_weather_com_cn_code_and_name('101210801','丽水').nil?
    puts '金华--101210901 is not exists' if City.find_by_weather_com_cn_code_and_name('101210901','金华').nil?
    puts '衢州--101211001 is not exists' if City.find_by_weather_com_cn_code_and_name('101211001','衢州').nil?
    puts '舟山--101211101 is not exists' if City.find_by_weather_com_cn_code_and_name('101211101','舟山').nil?

  end
end